/* static/css/base.css - 所有页面共用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    height: 100vh;
    overflow: hidden; /* 避免页面整体滚动 */
}

/* 容器：侧边栏+主内容区 布局 */
.app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 1. 侧边栏样式（固定宽度，上下三部分结构） */
.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

/* 1.1 侧边栏-上部分：用户信息区 */
.sidebar-user {
    padding: 1.2rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar-container {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #4a6cf7;
    cursor: pointer;
}

.user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #f1f5f9; /* 默认背景色 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a6cf7;
    font-size: 1.5rem;
}

.avatar-upload {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #4a6cf7;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.user-info {
    text-align: center;
    width: 100%;
}

.user-name {
    font-weight: 600;
    font-size: 1rem;
    color: #1e293b;
}

.user-role {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.auth-btn {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn {
    background: #4a6cf7;
    color: white;
}

.login-btn:hover {
    background: #3a5ae7;
}

.logout-btn {
    background: #f8fafc;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.logout-btn:hover {
    background: #fef2f2;
}

/* 1.2 侧边栏-中间部分：聊天功能区 */
.sidebar-chat {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.new-chat-btn {
    padding: 0.8rem;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    color: #4a6cf7;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: #e0e7ff;
    border-color: #4a6cf7;
}

.chat-history-header {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    padding: 0 0.2rem;
}

.chat-history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-history-item {
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    background: #f8fafc;
    color: #1e293b;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
}

.chat-history-item:hover {
    background: #e0e7ff;
    color: #4a6cf7;
}

.history-more {
    padding: 0.4rem 0.8rem;
    color: #4a6cf7;
    font-size: 0.8rem;
    text-align: center;
    cursor: pointer;
}

/* 1.3 侧边栏-下部分：配置按钮区 */
.sidebar-config {
    padding: 1rem;
    border-top: 1px solid #e9ecef;
}

.config-btn {
    width: 100%;
    padding: 0.8rem;
    background: #f8fafc;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    color: #1e293b;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.config-btn:hover {
    background: #e9ecef;
}

/* 2. 主内容区样式 */
.main-content {
    flex: 1;
    background: #f8fafc;
    height: 100vh;
    overflow-y: auto;
}

/* 2.1 主内容区-首次加载：项目介绍 */
.intro-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.intro-logo {
    font-size: 3rem;
    color: #4a6cf7;
    margin-bottom: 1.5rem;
}

.intro-title {
    font-size: 2rem;
    color: #1e293b;
    margin-bottom: 1rem;
}

.intro-desc {
    font-size: 1.1rem;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.features-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    width: 100%;
}

.feature-card {
    background: white;
    padding: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: left;
}

.feature-icon {
    font-size: 1.5rem;
    color: #4a6cf7;
    margin-bottom: 0.8rem;
}

.feature-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.feature-desc {
    font-size: 0.9rem;
    color: #64748b;
}

.model-intro {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: 100%;
    text-align: left;
}

.model-intro-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 2.2 主内容区-登录/注册表单（覆盖intro） */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.auth-modal {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.tab {
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab.active {
    border-bottom-color: #4a6cf7;
    color: #4a6cf7;
    font-weight: 500;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #1e293b;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.auth-button {
    width: 100%;
    padding: 0.8rem;
    background: #4a6cf7;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-button:hover {
    background: #3a5ae7;
}

.error-message {
    color: #dc3545;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    background: #f8d7da;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.success-message {
    color: #28a745;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    background: #d4edda;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.close-auth {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
}

/* 2.3 主内容区-聊天页面 */
.chat-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    font-size: 1.1rem;
    color: #1e293b;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    overflow-y: auto;
}

.message {
    max-width: 70%;
    padding: 0.9rem 1.2rem;
    border-radius: 8px;
    word-wrap: break-word;
}

.user-message {
    background: #4a6cf7;
    color: white;
    align-self: flex-end;
}

.assistant-message {
    background: white;
    color: #1e293b;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.message-meta {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    opacity: 0.8;
}

.typing-indicator {
    color: #64748b;
    padding: 0.9rem 1.2rem;
    align-self: flex-start;
    font-size: 0.9rem;
}

.chat-input-container {
    padding: 1.2rem 2rem;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.8rem;
}

.chat-input {
    flex: 1;
    padding: 0.9rem 1.2rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    resize: none;
    height: 50px;
}

.send-btn {
    padding: 0 1.5rem;
    background: #4a6cf7;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #3a5ae7;
}

/* 2.4 主内容区-配置页面 */
.config-page {
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.config-header {
    margin-bottom: 2rem;
}

.config-title {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.config-tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.config-tab {
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: #64748b;
    font-weight: 500;
}

.config-tab.active {
    color: #4a6cf7;
    border-bottom: 2px solid #4a6cf7;
}

.config-content {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex: 1;
}

/* 配置-用户管理表格 */
.user-table, .api-key-table {
    width: 100%;
    border-collapse: collapse;
}

.user-table th, .user-table td,
.api-key-table th, .api-key-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.user-table th, .api-key-table th {
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-table td, .api-key-table td {
    color: #1e293b;
    font-size: 0.9rem;
}

/* 配置-API Key管理 */
.key-action-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid #4a6cf7;
    color: #4a6cf7;
}

.key-display {
    font-family: monospace;
    color: #64748b;
}

/* 配置-AI模型配置 */
.model-config-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.model-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-form-group label {
    font-weight: 500;
    color: #1e293b;
}

.model-form-group input {
    padding: 0.8rem;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 1rem;
}

.save-model-btn {
    align-self: flex-start;
    padding: 0.8rem 1.5rem;
    background: #4a6cf7;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* */
.chat-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
  }
  .chat-history-item:hover {
    background: rgba(255, 255, 255, 0.08);
  }
  .history-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .delete-history-btn {
    color: #999;
    font-size: 0.9em;
    padding: 0.2rem;
    visibility: hidden;
  }
  .chat-history-item:hover .delete-history-btn {
    visibility: visible;
  }
  .delete-history-btn:hover {
    color: #e74c3c;
  }

/* 错误重发 */
.retry-icon {
    color: #e74c3c;
    margin-left: 0.5rem;
    cursor: pointer;
  }
  .retry-icon:hover {
    transform: rotate(90deg);
  }
  
  
  /* Think 折叠 */
.think-wrapper{margin:.5rem 0;}
.think-box{border-left:3px solid #909399;background:#f5f7fa;padding:.4rem .6rem;font-size:.9em;}
.think-content-wrapper{display:flex;align-items:center;}
.think-spinner{margin-right:.4rem;color:#409eff;}
.think-content{white-space:pre-wrap;margin:0;}

/* Markdown 表格 */
.md-table{width:100%;border-collapse:collapse;margin:.6rem 0;}
.md-table th,.md-table td{border:1px solid #dcdfe6;padding:.4rem .6rem;text-align:left;}
.md-table th{background:#f5f7fa;font-weight:600;}

/* 代码 / 行内代码 / 复制按钮 同前 */
.code-block{margin:.6rem 0;border:1px solid #dcdfe6;border-radius:4px;overflow:hidden;}
.code-header{display:flex;justify-content:space-between;align-items:center;padding:.3rem .6rem;background:#f5f7fa;font-size:.85em;}
.code-lang{color:#606266;}
.copy-btn{border:none;background:transparent;cursor:pointer;color:#409eff;}
.copy-btn:hover{color:#66b1ff;}
.code-content{margin:0;padding:.6rem;background:#fafafa;overflow-x:auto;}
.inline-code{padding:2px 4px;background:#eef1f5;border-radius:3px;font-family:Consolas,Monaco,monospace;}

/* 通用隐藏类 */
.hidden {
    display: none !important;
}